﻿@model WebApp.NavModel
@{
    ViewBag.Title = "Home Page";    
}

@if (WebApp.SiteStructure.Instance[Model.mi].blnHasBeforeContent)
{
    string content = WebApp.SiteStructure.Instance[Model.mi].BeforeContent;
    <text>@Html.Raw(content)</text>           
}

    @if (WebApp.SiteStructure.Instance[Model.mi].Tabs != null && WebApp.SiteStructure.Instance[Model.mi].Tabs.Count > 0)
    {
        <ul class="nav nav-tabs">
            @foreach (WebApp.TabItem wTab in WebApp.SiteStructure.Instance[Model.mi].Tabs)
            {
            string wActive = "";
            if (wTab.Name == Model.tab || string.IsNullOrWhiteSpace(Model.tab))
            {
            wActive = "active";
            Model.tab = wTab.Name;
            }
            <li role="presentation" class="@wActive"><a href="~/Home/Content?mi=@HttpUtility.UrlEncode(Model.mi)&tab=@HttpUtility.UrlEncode(wTab.Name)&dd=@HttpUtility.UrlEncode(Model.dd)&dd2=@HttpUtility.UrlEncode(Model.dd2)&dd3=@HttpUtility.UrlEncode(Model.dd3)">@wTab.Name</a></li>
            }
        </ul>
    }

@if (!string.IsNullOrWhiteSpace(Model.tab))
{
    <br />
        
    if (WebApp.SiteStructure.Instance[Model.mi][Model.tab].blnHasBeforeContent)
    {
        string content = WebApp.SiteStructure.Instance[Model.mi][Model.tab].BeforeContent;
        <text>@Html.Raw(content)</text>        
    }

    if (WebApp.SiteStructure.Instance[Model.mi][Model.tab].GetDropdownListItems(Model.dd).Count() > 1 && WebApp.SiteStructure.Instance[Model.mi][Model.tab] != null)
    { 
        using (Html.BeginForm("Content", "Home", FormMethod.Post, new { id = "MEAForm" }))
        {
            <div>
                @Html.HiddenFor(m => m.mi)
                @Html.HiddenFor(m => m.tab)
                @Html.DropDownListFor(m => m.dd, WebApp.SiteStructure.Instance[Model.mi][Model.tab].GetDropdownListItems(Model.dd), new { @onchange = "document.getElementById('MEAForm').submit();" })
                <br />
                <br />
                @if (!string.IsNullOrWhiteSpace(Model.dd))
                {
                    if (WebApp.SiteStructure.Instance[Model.mi][Model.tab][Model.dd] != null && WebApp.SiteStructure.Instance[Model.mi][Model.tab][Model.dd].Content != null)
                    {
                        <text>@Html.Raw(WebApp.SiteStructure.Instance[Model.mi][Model.tab][Model.dd].Content)</text>
                    }
                }
            
            </div>
        }
    }
    
    if (WebApp.SiteStructure.Instance[Model.mi][Model.tab].blnHasAfterContent)
    {
        <text>@Html.Raw(WebApp.SiteStructure.Instance[Model.mi][Model.tab].AfterContent)</text>
    }
}

@if (WebApp.SiteStructure.Instance[Model.mi].blnHasAfterContent)
{
    <text>@Html.Raw(WebApp.SiteStructure.Instance[Model.mi].AfterContent)</text>
}

